
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;

public class CompanyRegisterServlet extends HttpServlet
{
  
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
  {

     try
       {

        String company_uname=request.getParameter("company_uname");
        String company_pwd=request.getParameter("company_pwd");
        String company_name=request.getParameter("company_name");
        String website=request.getParameter("website");
        String email=request.getParameter("email");
        String tel_no=request.getParameter("tel_no");
 String ssc=request.getParameter("ssc");
   String inter=request.getParameter("inter");
  String graduation=request.getParameter("graduation");
 String pg=request.getParameter("pg");

 String pg_year=request.getParameter("pg_year");
 String technical_skills=request.getParameter("technical_skills");
 String designation=request.getParameter("designation");




           Class.forName("oracle.jdbc.driver.OracleDriver");
         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","pac","mca"); 


         PreparedStatement pstmt1=con.prepareStatement("insert into company_login values(?,?)");
         
         pstmt1.setString(1,company_uname);
         pstmt1.setString(2,company_pwd);
       
         pstmt1.executeUpdate();


         PreparedStatement pstmt2=con.prepareStatement("insert into company_register values(?,?,?,?,?)");
         
         pstmt2.setString(1,company_name);
         pstmt2.setString(2,website);
         pstmt2.setString(3,email);
         pstmt2.setString(4,tel_no);
         pstmt2.setString(5,company_uname);

         pstmt2.executeUpdate();
 PreparedStatement pstmt3=con.prepareStatement("insert into company_requirement values(?,?,?,?,?,?,?,?)");
         
         pstmt3.setString(1,ssc);
         pstmt3.setString(2,inter);
         pstmt3.setString(3,graduation);
         pstmt3.setString(4,pg);
       pstmt3.setString(5,pg_year);
       pstmt3.setString(6,technical_skills);
pstmt3.setString(7,designation);
 
 pstmt3.setString(8,company_uname);
         pstmt3.executeUpdate();

         response.setContentType("text/html");

         PrintWriter out=response.getWriter();
        

         out.println("<html>");
     
         out.println("<body background=\"t11.jpg\">");
 
         out.println(" <font size=\"4\"> ");
  
         out.println("<br> <b>Registered Successfully </b>");

         out.println("<br><br> <b> <a href=\"company-login.html\"> <font color=\"blue\"> Click here </font> </a> to Login </b>");

         out.println("</font>");

         out.println("</body>");

         out.println("</html>");   

 }
 
    catch(Exception e)
       {
         response.sendError(505,e.getMessage());
         e.printStackTrace();
       }    

  }

}  

 